/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DRIVER_EXTERNAL_DEVICE_NOTIFICATION_LOCALE_H
#define DRIVER_EXTERNAL_DEVICE_NOTIFICATION_LOCALE_H

#include <fstream>
#include <mutex>
#include <string>
#include <unistd.h>
#include <unordered_map>
#include <cJSON.h>
#include "nocopyable.h"

namespace OHOS {
namespace ExternalDeviceManager {
class NotificationLocale : public NoCopyable {
public:
    static NotificationLocale &GetInstance();

    void ParseLocaleCfg();

    void UpdateStringMap();

    std::string GetStringByKey(const std::string &key);

    // // base bo_CN ug zh_CN zh_HK zh_TW zz_ZX. 临时代码上库前需要删除
    // void SetLanguage(const std::string &language) {
    //     curLanguage_ = language;
    // }

    // // 临时代码上库前需要删除
    // std::string GetLanguage() const {
    //     return curLanguage_;
    // }
private:
    bool ParseJsonfile(const std::string &targetPath, std::unordered_map<std::string, std::string> &container);
    std::unordered_map<std::string, std::string> languageMap_;
    std::unordered_map<std::string, std::string> stringMap_;
    std::string localeBaseName_;
    // std::string curLanguage_;  //临时代码上库前需要删除
    std::atomic<bool> islanguageMapInit_{false};
    static std::mutex mutex_;
    static std::shared_ptr<NotificationLocale> instance_;
};
} // namespace ExternalDeviceManager
} // namespace OHOS

#endif // DRIVER_EXTERNAL_DEVICE_NOTIFICATION_LOCALE_H